package com.example.dell.startproject212lh.modl;

import com.example.dell.startproject212lh.Ibace.WeatherListener;
import com.example.dell.startproject212lh.Ibace.Weatheribean;
import com.example.dell.startproject212lh.bean.Weatherresult;
import com.example.dell.startproject212lh.servrce.Weatherservrce;
import com.squareup.picasso.Downloader;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by DELL on 2017/3/15.
 */

public class Weather51modl implements Weatheribean {

    private Retrofit retrofit;
    private Weatherservrce weatherService;
    private static final String BASE_URL = "http://www.weather.com.cn/";
    public Weather51modl() {
        retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)               //主机地址
                .addConverterFactory(GsonConverterFactory.create()) //解析方式
                .build();
    }

    @Override
    public void getWeather(String cityno, final WeatherListener listener) {
        weatherService = retrofit.create(Weatherservrce.class);
        Call<Weatherresult> call = weatherService.getResult(cityno);
        call.enqueue(new Callback<Weatherresult>() {
            @Override
            public void onResponse(Call<Weatherresult> call, Response<Weatherresult> response) {
                if(response.isSuccessful()&&response.body()!=null){

                }
            }

            @Override
            public void onFailure(Call<Weatherresult> call, Throwable t) {

            }
        });

    }
}
